FROM php:7.1-apache
ENV DEBIAN_FRONTEND noninteractive

# 更新安装源
#RUN sed -i 's/deb.debian.org/mirrors.aliyun.com/g' /etc/apt/sources.list
RUN sed -i "s/archive.ubuntu./mirrors.aliyun./g" /etc/apt/sources.list
RUN sed -i "s/deb.debian.org/mirrors.aliyun.com/g" /etc/apt/sources.list
RUN apt-get update
RUN apt-get install -y  apt-utils

# 安装PHP扩展
RUN mkdir -p /usr/src/php/ext
WORKDIR /usr/src/php/ext
RUN apt-get install -y libxml2-dev
RUN apt-get install -y libxslt-dev
RUN docker-php-ext-install soap
RUN docker-php-ext-install xsl
RUN apt-get install -y libbz2-dev
RUN apt-get install -y zlib1g-dev
RUN docker-php-ext-install bz2
RUN docker-php-ext-install zip
RUN docker-php-ext-install pdo_mysql
RUN docker-php-ext-install exif
RUN docker-php-ext-install bcmath
RUN docker-php-ext-install calendar
RUN docker-php-ext-install sockets
RUN docker-php-ext-install gettext
RUN docker-php-ext-install shmop
RUN docker-php-ext-install sysvmsg
RUN docker-php-ext-install sysvsem
RUN docker-php-ext-install sysvshm
RUN docker-php-ext-install opcache
RUN apt-get install -y libmcrypt-dev
RUN docker-php-ext-install mcrypt
RUN docker-php-ext-install wddx
RUN docker-php-ext-install pcntl

# 安装GD扩展
RUN apt-get install -y libfreetype6-dev
RUN apt-get install -y libjpeg62-turbo-dev
RUN apt-get install -y libpng-dev
RUN apt-get install -y libcurl3-dev
RUN docker-php-ext-configure gd \
    --with-freetype-dir=/usr/include/ \
    --with-jpeg-dir=/usr/include/
RUN docker-php-ext-install gd

## 安装Redis扩展
#ADD deploy/redis-4.0.2.tar.gz .
#RUN mv redis-4.0.2 redis
#RUN docker-php-ext-install redis
#
##安装mysql拓展
#ADD deploy/mysql .
#RUN docker-php-ext-install mysql

#安装mysqli拓展
ADD deploy/mysqli .
RUN docker-php-ext-install mysqli


## 安装Solr扩展
#ADD deploy/solr-2.4.0.tar .
#RUN mv solr-2.4.0 solr
#RUN docker-php-ext-install solr


# 部署环境
RUN rm -rf /var/www/*
RUN rm -rf /etc/apache2/sites-available/*
RUN rm -rf /etc/apache2/sites-enabled/*
COPY deploy/apache.conf /etc/apache2/apache2.conf
COPY deploy/rewrite.load /etc/apache2/mods-enabled/rewrite.load
COPY deploy/sites.conf /etc/apache2/sites-enabled/sites.conf
COPY /deploy/php/php.ini /usr/local/etc/php/php.ini

# 部署项目
#COPY / /var/www/
RUN mkdir -p /var/www/runtime
RUN chmod -R 777 /var/www/

# 从国内镜像安装composer，并配置成默认从国内镜像安装composer包
RUN curl -sS https://install.phpcomposer.com/installer | php -- --install-dir=/usr/local/bin/ --filename=composer
#RUN composer config -g repo.packagist composer https://packagist.laravel-china.org
RUN composer config -g repo.packagist composer https://mirrors.aliyun.com/composer/

# 启动服务
WORKDIR /var/www/public